import java.util.Arrays;

public class num1109 {
//    public int[] corpFlightBookings(int[][] bookings, int n) {
//        int[] arr = new int[n];
//        for(int[] nums : bookings) {
//                int count = nums[1] - nums[0] + 1;
//                int temp = nums[0];
//            for (int i = 0; i < count; i++) {
//                arr[temp- 1] += nums[2];
//                temp ++;
//            }
//        }
//        return arr;
//    }
public static void main(String[] args) {
    int[][] nums = new int[][]{{1,2,10},{2,3,20},{2,5,25}};
    System.out.println(Arrays.toString(corpFlightBookings(nums,5)));
}
    public static int[] corpFlightBookings(int[][] bookings, int n) {
        int[] nums = new int[n];
        for (int[] booking : bookings) {
            //第booking[0]站上车
            nums[booking[0] - 1] += booking[2];
            if (booking[1] < n) {
                //第booking[1] + 1站下车
                nums[booking[1]] -= booking[2];
            }
        }
        //加上前面没下车的人
        for (int i = 1; i < n; i++) {
            nums[i] += nums[i - 1];
        }
        return nums;
    }
}

